package com.smartscreen.lifeserviceinfomanage.controller;

import com.smartscreen.common.response.ApiResponse;
import com.smartscreen.lifeserviceinfomanage.dto.*;
import com.smartscreen.lifeserviceinfomanage.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/life-service")
public class LifeServiceController {
    
    @Autowired
    private CampusMapService campusMapService;
    
    @Autowired
    private CanteenService canteenService;
    
    @Autowired
    private LibraryService libraryService;
    
    @Autowired
    private ShuttleBusService shuttleBusService;
    
    @Autowired
    private WeatherService weatherService;
    
    /**
     * 获取校园地图POI数据
     */
    @GetMapping("/campus-map/pois")
    public ApiResponse<List<CampusMapPoiDTO>> getCampusMapPois() {
        List<CampusMapPoiDTO> pois = campusMapService.getAllPois();
        return ApiResponse.success(pois);
    }
    
    /**
     * 获取餐厅列表
     */
    @GetMapping("/canteens")
    public ApiResponse<List<CanteenListDTO>> getCanteens() {
        List<CanteenListDTO> canteens = canteenService.getAllCanteens();
        return ApiResponse.success(canteens);
    }
    
    /**
     * 获取指定餐厅详情
     */
    @GetMapping("/canteens/{canteenId}")
    public ApiResponse<CanteenDetailDTO> getCanteenDetail(@PathVariable String canteenId) {
        CanteenDetailDTO canteen = canteenService.getCanteenDetail(canteenId);
        return ApiResponse.success(canteen);
    }
    
    /**
     * 获取图书馆状态
     */
    @GetMapping("/library/status")
    public ApiResponse<LibraryStatusDTO> getLibraryStatus() {
        LibraryStatusDTO status = libraryService.getLibraryStatus();
        return ApiResponse.success(status);
    }
    
    /**
     * 获取班车时刻表
     */
    @GetMapping("/shuttle-bus/schedule")
    public ApiResponse<List<ShuttleBusScheduleDTO>> getShuttleBusSchedule() {
        List<ShuttleBusScheduleDTO> schedules = shuttleBusService.getSchedule();
        return ApiResponse.success(schedules);
    }
    
    /**
     * 获取当前天气
     */
    @GetMapping("/weather/now")
    public ApiResponse<WeatherNowDTO> getCurrentWeather() {
        WeatherNowDTO weather = weatherService.getCurrentWeather();
        return ApiResponse.success(weather);
    }
    
    /**
     * 获取天气预报
     */
    @GetMapping("/weather/forecast")
    public ApiResponse<List<WeatherForecastDTO>> getWeatherForecast(@RequestParam(defaultValue = "3") Integer days) {
        List<WeatherForecastDTO> forecasts = weatherService.getWeatherForecast(days);
        return ApiResponse.success(forecasts);
    }
}